<!DOCTYPE html>
<html lang="en">
  <head>
    <title>USERGUIDE  Reference</title>
    <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="css/highlight.css" />
    <meta charset="utf-8">
    <script src="js/jquery.min.js" defer></script>
    <script src="js/jazzy.js" defer></script>
    
    <script src="js/lunr.min.js" defer></script>
    <script src="js/typeahead.jquery.js" defer></script>
    <script src="js/jazzy.search.js" defer></script>
  </head>
  <body>


    <a title="USERGUIDE  Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="index.html">
          EFQRCode Docs
        </a>
         (0% documented)
      </p>
    
      <p class="header-col--secondary">
        <form role="search" action="search.json">
          <input type="text" placeholder="Search documentation" data-typeahead>
        </form>
      </p>
    
    
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="index.html">EFQRCode Reference</a>
      <img class="carat" src="img/carat.png" />
      USERGUIDE  Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Guides.html">Guides</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="userguide.html">USERGUIDE</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content">
            
            <h2 id='user-guide' class='heading'>User Guide</h2>
<h3 id='1-recognition' class='heading'>1. Recognition</h3>
<pre class="highlight swift"><code><span class="kt">EFQRCode</span><span class="o">.</span><span class="nf">recognize</span><span class="p">(</span><span class="nv">image</span><span class="p">:</span> <span class="kt">CGImage</span><span class="p">)</span>
</code></pre>

<p>Or</p>
<pre class="highlight swift"><code><span class="kt">EFQRCodeRecognizer</span><span class="p">(</span><span class="nv">image</span><span class="p">:</span> <span class="kt">CGImage</span><span class="p">)</span><span class="o">.</span><span class="nf">recognize</span><span class="p">()</span>
</code></pre>

<p>Two way before is exactly the same, because of the possibility of more than one two-dimensional code in the same iamge, so the return value is `[String]? &lsquo;, if the return is nil means that the input data is incorrect or null. If the return array is empty, it means we can not recognize  any two-dimensional code at the image.</p>
<h3 id='2-generation' class='heading'>2. Generation</h3>
<pre class="highlight swift"><code><span class="kt">EFQRCode</span><span class="o">.</span><span class="nf">generate</span><span class="p">(</span>
    <span class="nv">content</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span>
    <span class="nv">size</span><span class="p">:</span> <span class="kt">EFIntSize</span><span class="p">,</span>
    <span class="nv">backgroundColor</span><span class="p">:</span> <span class="kt">CIColor</span><span class="p">,</span>
    <span class="nv">foregroundColor</span><span class="p">:</span> <span class="kt">CIColor</span><span class="p">,</span>
    <span class="nv">watermark</span><span class="p">:</span> <span class="kt">CGImage</span><span class="p">?</span>
<span class="p">)</span>
</code></pre>

<p>Or</p>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">generator</span> <span class="o">=</span> <span class="kt">EFQRCodeGenerator</span><span class="p">(</span><span class="nv">content</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">size</span><span class="p">:</span> <span class="kt">EFIntSize</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setContent</span><span class="p">(</span><span class="nv">content</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setMode</span><span class="p">(</span><span class="nv">mode</span><span class="p">:</span> <span class="kt">EFQRCodeMode</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setInputCorrectionLevel</span><span class="p">(</span><span class="nv">inputCorrectionLevel</span><span class="p">:</span> <span class="kt">EFInputCorrectionLevel</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setSize</span><span class="p">(</span><span class="nv">size</span><span class="p">:</span> <span class="kt">EFIntSize</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setMagnification</span><span class="p">(</span><span class="nv">magnification</span><span class="p">:</span> <span class="kt">EFIntSize</span><span class="p">?)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setColors</span><span class="p">(</span><span class="nv">backgroundColor</span><span class="p">:</span> <span class="kt">CIColor</span><span class="p">,</span> <span class="nv">foregroundColor</span><span class="p">:</span> <span class="kt">CIColor</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setIcon</span><span class="p">(</span><span class="nv">icon</span><span class="p">:</span> <span class="kt">CGImage</span><span class="p">?,</span> <span class="nv">size</span><span class="p">:</span> <span class="kt">EFIntSize</span><span class="p">?)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setWatermark</span><span class="p">(</span><span class="nv">watermark</span><span class="p">:</span> <span class="kt">CGImage</span><span class="p">?,</span> <span class="nv">mode</span><span class="p">:</span> <span class="kt">EFWatermarkMode</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setForegroundPointOffset</span><span class="p">(</span><span class="nv">foregroundPointOffset</span><span class="p">:</span> <span class="kt">CGFloat</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setAllowTransparent</span><span class="p">(</span><span class="nv">allowTransparent</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setPointShape</span><span class="p">(</span><span class="nv">pointShape</span><span class="p">:</span> <span class="kt">EFPointShape</span><span class="p">)</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">setBinarizationThreshold</span><span class="p">(</span><span class="nv">binarizationThreshold</span><span class="p">:</span> <span class="kt">CGFloat</span><span class="p">)</span>

<span class="c1">// Final two-dimensional code image we get</span>
<span class="n">generator</span><span class="o">.</span><span class="nf">generate</span><span class="p">()</span>
</code></pre>

<p>Two way before is exactly the same, the return value is <code>CGImage?</code>, if the return is nil means that there is some wrong during the generation.</p>
<h4 id='parameters-explaination' class='heading'>Parameters Explaination</h4>

<ul>
<li><strong>content: String?</strong></li>
</ul>

<p>Content, compulsive, capacity is limited, 1273 character most, the density of the two-dimensional lattice increases with the increase of the content. Comparison of different capacity is as follows:</p>

<table><thead>
<tr>
<th style="text-align: center">10 characters</th>
<th style="text-align: center">250 characters</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareContent1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareContent2.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>mode: EFQRCodeMode</strong></li>
</ul>

<p>Mode of QR Code, the definition of EFQRCodeMode:</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">EFQRCodeMode</span><span class="p">:</span> <span class="kt">Int</span> <span class="p">{</span>
    <span class="k">case</span> <span class="k">none</span>           <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">grayscale</span>      <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">binarization</span>   <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>

<table><thead>
<tr>
<th style="text-align: center">none</th>
<th style="text-align: center">grayscale</th>
<th style="text-align: center">binarization</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/mode1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/mode2.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/mode3.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>inputCorrectionLevel: EFInputCorrectionLevel</strong></li>
</ul>

<p>Error-tolerant rate, optional, 4 different level, L: 7% / M 15% / Q 25% / H 30%, default is H, the definition of EFInputCorrectionLevel:</p>
<pre class="highlight swift"><code><span class="c1">// EFInputCorrectionLevel</span>
<span class="kd">public</span> <span class="kd">enum</span> <span class="kt">EFInputCorrectionLevel</span><span class="p">:</span> <span class="kt">Int</span> <span class="p">{</span>
    <span class="k">case</span> <span class="n">l</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>     <span class="c1">// L 7%</span>
    <span class="k">case</span> <span class="n">m</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>     <span class="c1">// M 15%</span>
    <span class="k">case</span> <span class="n">q</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>     <span class="c1">// Q 25%</span>
    <span class="k">case</span> <span class="n">h</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span>     <span class="c1">// H 30%</span>
<span class="p">}</span>
</code></pre>

<p>Comparison of different inputCorrectionLevel:</p>

<table><thead>
<tr>
<th style="text-align: center">L</th>
<th style="text-align: center">M</th>
<th style="text-align: center">Q</th>
<th style="text-align: center">H</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareInputCorrectionLevel1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareInputCorrectionLevel2.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareInputCorrectionLevel3.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareInputCorrectionLevel4.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>size: EFIntSize</strong></li>
</ul>

<p>Two-dimensional code length, optional, default is 256 (PS: if magnification is not nil, size will be ignored), the definition of EFIntSize:</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">EFIntSize</span> <span class="p">{</span>
    <span class="kd">public</span> <span class="kd">private(set)</span> <span class="k">var</span> <span class="nv">width</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="kd">public</span> <span class="kd">private(set)</span> <span class="k">var</span> <span class="nv">height</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span>

    <span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">width</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">self</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="n">width</span>
        <span class="k">self</span><span class="o">.</span><span class="n">height</span> <span class="o">=</span> <span class="n">height</span>
    <span class="p">}</span>

    <span class="kd">public</span> <span class="kd">func</span> <span class="nf">toCGSize</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">CGSize</span> <span class="p">{</span>
        <span class="k">return</span> <span class="kt">CGSize</span><span class="p">(</span><span class="nv">width</span><span class="p">:</span> <span class="k">self</span><span class="o">.</span><span class="n">width</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="k">self</span><span class="o">.</span><span class="n">height</span><span class="p">)</span>
    <span class="p">}</span>

    <span class="kd">public</span> <span class="kd">func</span> <span class="nf">widthCGFloat</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">CGFloat</span> <span class="p">{</span>
        <span class="k">return</span> <span class="kt">CGFloat</span><span class="p">(</span><span class="n">width</span><span class="p">)</span>
    <span class="p">}</span>

    <span class="kd">public</span> <span class="kd">func</span> <span class="nf">heightCGFloat</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">CGFloat</span> <span class="p">{</span>
        <span class="k">return</span> <span class="kt">CGFloat</span><span class="p">(</span><span class="n">height</span><span class="p">)</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre>

<table><thead>
<tr>
<th style="text-align: center">234*234</th>
<th style="text-align: center">312*234</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/size1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/size2.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>magnification: EFIntSize?</strong></li>
</ul>

<p>Magnification, optional, default is nil.</p>

<p>Because by the existence of size scaling two-dimensional code clarity is not high, if you want to get a more clear two-dimensional code, you can use magnification to set the size of the final generation of two-dimensional code. Here is the smallest ratio relative to the two-dimensional code matrix is concerned, if there is a wanted size but I hope to have a clear and size and have size approximation of the two-dimensional code by using magnification, through <code>maxMagnificationLessThanOrEqualTo (size: CGFloat), and</code>minMagnificationGreaterThanOrEqualTo (size: CGFloat), want to get magnification these two functions the specific value, the use of specific methods are as follows:</p>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">generator</span> <span class="o">=</span> <span class="kt">EFQRCodeGenerator</span><span class="p">(</span>
    <span class="nv">content</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span>
    <span class="nv">inputCorrectionLevel</span><span class="p">:</span> <span class="kt">EFInputCorrectionLevel</span><span class="p">,</span>
    <span class="nv">size</span><span class="p">:</span> <span class="kt">EFIntSize</span><span class="p">,</span>
    <span class="nv">magnification</span><span class="p">:</span> <span class="kt">EFIntSize</span><span class="p">?,</span>
    <span class="nv">backgroundColor</span><span class="p">:</span> <span class="kt">CIColor</span><span class="p">,</span>
    <span class="nv">foregroundColor</span><span class="p">:</span> <span class="kt">CIColor</span>
<span class="p">)</span>

<span class="c1">// Want to get max magnification when size is less than or equalTo 600</span>
<span class="k">if</span> <span class="k">let</span> <span class="nv">magnification</span> <span class="o">=</span> <span class="n">generator</span><span class="o">.</span><span class="nf">maxMagnificationLessThanOrEqualTo</span><span class="p">(</span><span class="nv">size</span><span class="p">:</span> <span class="mi">600</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">generator</span><span class="o">.</span><span class="n">magnification</span> <span class="o">=</span> <span class="kt">EFIntSize</span><span class="p">(</span><span class="nv">width</span><span class="p">:</span> <span class="n">magnification</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="n">magnification</span><span class="p">)</span>
<span class="p">}</span>

<span class="c1">// Or</span>

<span class="c1">// Want to get min magnification when width is greater than or equalTo 600 and height is greater than or equalTo 800</span>
<span class="c1">// if let magnificationWidth = generator.minMagnificationGreaterThanOrEqualTo(size: 600),</span>
<span class="c1">//     let magnificationHeight = generator.minMagnificationGreaterThanOrEqualTo(size: 600) {</span>
<span class="c1">//     generator.magnification = EFIntSize(width: magnificationWidth, height: magnificationHeight)</span>
<span class="c1">// }</span>

<span class="c1">// Final two-dimensional code image</span>
<span class="n">generator</span><span class="o">.</span><span class="n">image</span>
</code></pre>

<table><thead>
<tr>
<th style="text-align: center">size 300</th>
<th style="text-align: center">magnification 9</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareMagnification1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareMagnification2.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>backgroundColor: CIColor</strong></li>
</ul>

<p>BackgroundColor, optional, default is white.</p>

<ul>
<li><strong>foregroundColor: CIColor</strong></li>
</ul>

<p>ForegroundColor, optional, color of code point, default is black.</p>

<table><thead>
<tr>
<th style="text-align: center">ForegroundColor set to red</th>
<th style="text-align: center">BackgroundColor set to gray</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareForegroundcolor.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareBackgroundcolor.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>icon: CGImage?</strong></li>
</ul>

<p>Icon image in the center of code image, optional, default is nil.</p>

<ul>
<li><strong>iconSize: CGFloat?</strong></li>
</ul>

<p>Size of icon image, optional, default is 20% of size: </p>

<table><thead>
<tr>
<th style="text-align: center">Default 20% size</th>
<th style="text-align: center">Set to 64</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareIcon.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareIconSize.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>watermark: CGImage?</strong></li>
</ul>

<p>Watermark image, optional, default is nil, for example: </p>

<table><thead>
<tr>
<th style="text-align: center">1</th>
<th style="text-align: center">2</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareWatermark1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareWatermark2.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>watermarkMode: EFWatermarkMode</strong></li>
</ul>

<p>The watermark placed in two-dimensional code position, optional, default is scaleAspectFill, refer to UIViewContentMode, you can treat the two-dimensional code as UIImageView, the definition of UIViewContentMode:</p>
<pre class="highlight swift"><code><span class="c1">// Like UIViewContentMode</span>
<span class="kd">public</span> <span class="kd">enum</span> <span class="kt">EFWatermarkMode</span><span class="p">:</span> <span class="kt">Int</span> <span class="p">{</span>
    <span class="k">case</span> <span class="n">scaleToFill</span>        <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">scaleAspectFit</span>     <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">scaleAspectFill</span>    <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">center</span>             <span class="o">=</span> <span class="mi">3</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">top</span>                <span class="o">=</span> <span class="mi">4</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">bottom</span>             <span class="o">=</span> <span class="mi">5</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">left</span>               <span class="o">=</span> <span class="mi">6</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">right</span>              <span class="o">=</span> <span class="mi">7</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">topLeft</span>            <span class="o">=</span> <span class="mi">8</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">topRight</span>           <span class="o">=</span> <span class="mi">9</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">bottomLeft</span>         <span class="o">=</span> <span class="mi">10</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">bottomRight</span>        <span class="o">=</span> <span class="mi">11</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>

<ul>
<li><strong>foregroundPointOffset: CGFloat</strong></li>
</ul>

<p>Foreground point offset, optional, default is 0, is not recommended to use, may make the two-dimensional code broken:</p>

<table><thead>
<tr>
<th style="text-align: center">0</th>
<th style="text-align: center">0.5</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareForegroundPointOffset1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareForegroundPointOffset2.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>allowTransparent: Bool</strong></li>
</ul>

<p>Allow watermark image transparent, optional, default is <code>true</code>:</p>

<table><thead>
<tr>
<th style="text-align: center">true</th>
<th style="text-align: center">false</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareAllowTransparent1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareAllowTransparent2.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>pointShape: EFPointShape</strong></li>
</ul>

<p>Shape of foreground point, default is <code>.square</code>, the definition of UIViewContentMode:</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">EFPointShape</span><span class="p">:</span> <span class="kt">Int</span> <span class="p">{</span>
    <span class="k">case</span> <span class="n">square</span>         <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">circle</span>         <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
    <span class="k">case</span> <span class="n">diamond</span>        <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>

<table><thead>
<tr>
<th style="text-align: center">square</th>
<th style="text-align: center">circle</th>
<th style="text-align: center">diamond</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/compareAllowTransparent1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/pointShape.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/pointDiamond.jpg" alt=""></td>
</tr>
</tbody></table>

<ul>
<li><strong>binarizationThreshold: CGFloat</strong></li>
</ul>

<p>Threshold for binarization (Only for mode binarization).</p>

<table><thead>
<tr>
<th style="text-align: center">Origin</th>
<th style="text-align: center">0.3</th>
<th style="text-align: center">0.5</th>
<th style="text-align: center">0.8</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/binarizationThreshold0.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/binarizationThreshold1.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/binarizationThreshold2.jpg" alt=""></td>
<td style="text-align: center"><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/binarizationThreshold3.jpg" alt=""></td>
</tr>
</tbody></table>
<h3 id='3-generation-from-gif' class='heading'>3. Generation from GIF</h3>

<ol>
<li>First you should get the complete data of a GIF file, type is <code>Data</code>, can not get from <code>UIImage</code> or you will only get the first frame;</li>
<li>Then you can create GIF QRCode with function <code>generateWithGIF</code> of class <code>EFQRCode</code>, for example:</li>
</ol>
<pre class="highlight swift"><code><span class="c1">//                  data: Data of input GIF</span>
<span class="c1">//             generator: An object of EFQRCodeGenerator, use for setting</span>
<span class="c1">// pathToSave (Optional): Path to save the output GIF, default is temp path</span>
<span class="c1">//      delay (Optional): Output QRCode GIF delay, default is same as input GIF</span>
<span class="c1">//  loopCount (Optional): Output QRCode GIF loopCount, default is same as input GIF</span>
</code></pre>

<p>The <code>generator</code> here is an object of class <code>EFQRCodeGenerator</code>, to process each frame in GIF, you can find the use of it above.</p>
<pre class="highlight swift"><code><span class="k">if</span> <span class="k">let</span> <span class="nv">qrcodeData</span> <span class="o">=</span> <span class="kt">EFQRCode</span><span class="o">.</span><span class="nf">generateWithGIF</span><span class="p">(</span><span class="nv">data</span><span class="p">:</span> <span class="n">data</span><span class="p">,</span> <span class="nv">generator</span><span class="p">:</span> <span class="n">generator</span><span class="p">)</span> <span class="p">{</span>
    <span class="nf">print</span><span class="p">(</span><span class="s">"Create QRCode image success."</span><span class="p">)</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
    <span class="nf">print</span><span class="p">(</span><span class="s">"Create QRCode image failed!"</span><span class="p">)</span>
<span class="p">}</span>
</code></pre>

<p>You can get more information from the demo, result will like this:</p>

<p><img src="https://raw.githubusercontent.com/EFPrefix/EFQRCode/assets/QRCodeGIF6.gif" width = "42%"/></p>

<ol>
<li>Now you can get the complete data of output QRCode GIF, next we can save it to local path / system photo library / upload to server or some other things you want to do;</li>
<li>Emmmmmm, note that the <code>tempResultPath</code> of <code>EFQRcode</code> is the path of data of GIF of last generation.</li>
</ol>

          </div>
        </section>


      </article>
    </div>
    <section class="footer">
      <p>&copy; 2019 <a class="link" href="https://github.com/EFPrefix/EFQRCode" target="_blank" rel="external">EyreFree</a>. All rights reserved. (Last updated: 2019-04-12)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
